<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>
    <!-- load css -->
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/font/iconfont.css}" media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/layui/css/layui.css}"  media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/bootstrap/bootstrap/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/bootstrap-table/bootstrap-table.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/css/table.css}"  media="all"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/bootstrap/bootstrap/css/bootstrap.min.css}"/>
    <link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/select2/css/select2.css}" media="all"/>

    <style>

        /*.wizard {*/
        /*-webkit-border-radius: 2px;*/
        /*-webkit-background-clip: padding-box;*/
        /*-moz-border-radius: 2px;*/
        /*-moz-background-clip: padding;*/
        /*border-radius: 2px;*/
        /*background-clip: padding-box;*/
        /*-webkit-box-shadow: 0 0 4px rgba(0, 0, 0, .3);*/
        /*-moz-box-shadow: 0 0 4px rgba(0, 0, 0, .3);*/
        /*box-shadow: 0 0 4px rgba(0, 0, 0, .3);*/
        /*background-color: #fff;*/
        /*position: relative;*/
        /*overflow: hidden*/
        /*}*/

        /*.wizard.wizard-tabbed {*/
        /*background: #fbfbfb*/
        /*}*/

        /*.wizard.wizard-tabbed ul li {*/
        /*padding: 0 30px;*/
        /*background-color: #fbfbfb*/
        /*}*/

        /*.wizard.wizard-tabbed ul li .chevron {*/
        /*display: none*/
        /*}*/

        /*.wizard.wizard-tabbed ul li .chevron:before {*/
        /*display: none*/
        /*}*/

        /*.wizard.wizard-tabbed ul li.complete {*/
        /*background-color: #fbfbfb*/
        /*}*/

        /*.wizard.wizard-tabbed ul li.active {*/
        /*background: #fff*/
        /*}*/

        /*.wizard.wizard-wired {*/
        /*padding-top: 10px;*/
        /*display: block;*/
        /*background: #fff;*/
        /*text-align: center;*/
        /*-webkit-box-shadow: none;*/
        /*-moz-box-shadow: none;*/
        /*box-shadow: none;*/
        /*border-bottom: 1px solid #eee*/
        /*}*/

        /*.wizard.wizard-wired ul {*/
        /*display: table;*/
        /*width: 100%;*/
        /*position: relative*/
        /*}*/

        /*.wizard.wizard-wired ul li {*/
        /*display: table-cell;*/
        /*text-align: center;*/
        /*background-color: #fff;*/
        /*width: 20%;*/
        /*padding: 0;*/
        /*margin: 0;*/
        /*-webkit-transition: all 1s ease;*/
        /*-moz-transition: all 1s ease;*/
        /*-o-transition: all 1s ease;*/
        /*transition: all 1s ease*/
        /*}*/

        /*.wizard.wizard-wired ul li .chevron {*/
        /*display: none*/
        /*}*/

        /*.wizard.wizard-wired ul li .chevron:before {*/
        /*display: none*/
        /*}*/

        /*.wizard.wizard-wired ul li.complete {*/
        /*background-color: #fff*/
        /*}*/

        /*.wizard.wizard-wired ul li.complete .step:before {*/
        /*font-size: 22px;*/
        /*line-height: 36px*/
        /*}*/

        /*.wizard.wizard-wired ul li.complete:hover {*/
        /*background-color: #fff*/
        /*}*/

        /*.wizard.wizard-wired ul li.active {*/
        /*background-color: #fff*/
        /*}*/

        /*.wizard.wizard-wired ul li .step {*/
        /*border-width: 2px;*/
        /*width: 40px;*/
        /*height: 40px;*/
        /*line-height: 34px;*/
        /*font-size: 15px;*/
        /*z-index: 2;*/
        /*background-color: #fff*/
        /*}*/

        /*.wizard.wizard-wired ul li .title {*/
        /*display: block;*/
        /*margin-top: 4px;*/
        /*margin-bottom: 6px;*/
        /*max-width: 100%;*/
        /*font-size: 14px;*/
        /*line-height: 20px;*/
        /*z-index: 104;*/
        /*text-align: center;*/
        /*table-layout: fixed;*/
        /*-ms-word-wrap: break-word;*/
        /*word-wrap: break-word*/
        /*}*/

        /*.wizard.wizard-wired ul li:before {*/
        /*display: block;*/
        /*content: "";*/
        /*width: 100%;*/
        /*height: 2px !important;*/
        /*font-size: 0;*/
        /*overflow: hidden;*/
        /*background-color: #e5e5e5;*/
        /*position: relative !important;*/
        /*top: 25px;*/
        /*z-index: 1 !important*/
        /*}*/

        /*.wizard.wizard-wired ul li:first-child:before {*/
        /*max-width: 51%;*/
        /*left: 50%*/
        /*}*/

        /*.wizard.wizard-wired ul li:last-child:before {*/
        /*max-width: 50%;*/
        /*width: 50%*/
        /*}*/

        /*.wizard ul {*/
        /*list-style: none outside none;*/
        /*padding: 0;*/
        /*margin: 0;*/
        /*width: 4000px*/
        /*}*/

        /*.wizard ul.previous-disabled li.complete {*/
        /*cursor: default*/
        /*}*/

        /*.wizard ul.previous-disabled li.complete:hover {*/
        /*background: #f3f3f3;*/
        /*cursor: default*/
        /*}*/

        /*.wizard ul.previous-disabled li.complete:hover .chevron:before {*/
        /*border-left-color: #f3f3f3*/
        /*}*/

        /*.wizard ul li {*/
        /*float: left;*/
        /*margin: 0;*/
        /*padding: 0 20px 0 30px;*/
        /*line-height: 46px;*/
        /*position: relative;*/
        /*background: #f5f5f5;*/
        /*color: #d0d0d0;*/
        /*font-size: 16px;*/
        /*cursor: default;*/
        /*-webkit-transition: all .218s ease;*/
        /*-moz-transition: all .218s ease;*/
        /*-o-transition: all .218s ease;*/
        /*transition: all .218s ease*/
        /*}*/

        /*.wizard ul li .step {*/
        /*border: 2px solid #e5e5e5;*/
        /*color: #ccc;*/
        /*font-size: 13px;*/
        /*border-radius: 100%;*/
        /*position: relative;*/
        /*z-index: 2;*/
        /*display: inline-block;*/
        /*width: 24px;*/
        /*height: 24px;*/
        /*line-height: 20px;*/
        /*text-align: center;*/
        /*margin-right: 10px*/
        /*}*/

        /*.wizard ul li .chevron {*/
        /*border: 24px solid transparent;*/
        /*border-left: 14px solid #d4d4d4;*/
        /*border-right: 0;*/
        /*display: block;*/
        /*position: absolute;*/
        /*right: -14px;*/
        /*top: 0;*/
        /*z-index: 1*/
        /*}*/

        /*.wizard ul li .chevron:before {*/
        /*border: 24px solid transparent;*/
        /*border-left: 14px solid #f5f5f5;*/
        /*border-right: 0;*/
        /*content: "";*/
        /*display: block;*/
        /*position: absolute;*/
        /*right: 1px;*/
        /*top: -24px;*/
        /*-webkit-transition: all .218s ease;*/
        /*-moz-transition: all .218s ease;*/
        /*-o-transition: all .218s ease;*/
        /*transition: all .218s ease*/
        /*}*/

        /*.wizard ul li.complete {*/
        /*background: #f5f5f5;*/
        /*color: #444*/
        /*}*/

        /*.wizard ul li.complete:before {*/
        /*display: block;*/
        /*content: "";*/
        /*position: absolute;*/
        /*bottom: 0;*/
        /*left: 0;*/
        /*right: -1px;*/
        /*height: 2px;*/
        /*max-height: 2px;*/
        /*overflow: hidden;*/
        /*background-color: #a0d468;*/
        /*z-index: 10000*/
        /*}*/

        /*.wizard ul li.complete:hover {*/
        /*background: #eee;*/
        /*cursor: pointer*/
        /*}*/

        /*.wizard ul li.complete:hover .chevron:before {*/
        /*border-left: 14px solid #eee*/
        /*}*/

        /*.wizard ul li.complete .chevron:before {*/
        /*border-left: 14px solid #f5f5f5*/
        /*}*/

        /*.wizard ul li.complete .step {*/
        /*color: #a0d468;*/
        /*border-color: #a0d468*/
        /*}*/

        /*.wizard ul li.complete .step:before {*/
        /*display: block;*/
        /*position: absolute;*/
        /*top: 0;*/
        /*left: 0;*/
        /*bottom: 0;*/
        /*right: 0;*/
        /*line-height: 20px;*/
        /*text-align: center;*/
        /*border-radius: 100%;*/
        /*content: "";*/
        /*background-color: #fff;*/
        /*z-index: 3;*/
        /*font-family: FontAwesome;*/
        /*font-size: 12px;*/
        /*color: #a0d468*/
        /*}*/

        /*.wizard ul li.active {*/
        /*background: #fff;*/
        /*color: #262626*/
        /*}*/

        /*.wizard ul li.active .step {*/
        /*border-color: #2dc3e8;*/
        /*color: #2dc3e8*/
        /*}*/

        /*.wizard ul li.active:before {*/
        /*display: block;*/
        /*content: "";*/
        /*position: absolute;*/
        /*bottom: 0;*/
        /*left: 0;*/
        /*right: -1px;*/
        /*height: 2px;*/
        /*max-height: 2px;*/
        /*overflow: hidden;*/
        /*background-color: #2dc3e8;*/
        /*z-index: 10000*/
        /*}*/

        /*.wizard ul li.active .chevron:before {*/
        /*border-left: 14px solid #fff*/
        /*}*/

        /*.wizard ul li .badge {*/
        /*margin-right: 8px*/
        /*}*/

        /*.wizard ul li:first-child {*/
        /*-webkit-border-radius: 2px 0 0 0;*/
        /*-webkit-background-clip: padding-box;*/
        /*-moz-border-radius: 2px 0 0 0;*/
        /*-moz-background-clip: padding;*/
        /*border-radius: 2px 0 0 0;*/
        /*background-clip: padding-box;*/
        /*padding-left: 20px*/
        /*}*/

        /*.step-content {*/
        /*border-top: 0;*/
        /*-webkit-border-radius: 0 0 2px 2px;*/
        /*-webkit-background-clip: padding-box;*/
        /*-moz-border-radius: 0 0 2px 2px;*/
        /*-moz-background-clip: padding;*/
        /*border-radius: 0 0 2px 2px;*/
        /*background-clip: padding-box;*/
        /*padding: 10px;*/
        /*margin-bottom: 10px;*/
        /*-webkit-box-shadow: 1px 0 10px 1px rgba(0, 0, 0, .3);*/
        /*-moz-box-shadow: 1px 0 10px 1px rgba(0, 0, 0, .3);*/
        /*box-shadow: 1px 0 10px 1px rgba(0, 0, 0, .3);*/
        /*background-color: #fbfbfb*/
        /*}*/

        /*.step-content .step-pane {*/
        /*display: none*/
        /*}*/

        /*.step-content .active {*/
        /*display: inline;*/
        /*}*/

        /*.step-content .active .btn-group .active {*/
        /*display: inline-block*/
        /*}*/
        /*.wizard{*/
        /*position: fixed;*/
        /*z-index:9999;*/
        /*}*/
        /*.actions .btn-group, .btn-group-vertical{*/
        /*left: 5%;*/
        /*}*/
        h2{
            margin: 0;
        }
        .gysSave {
            background-color: dodgerblue; /* Green */
            border: none;
            border-radius: 100px;
            color: white;
            padding: 0.5px 14px;
            text-align: center;
            text-decoration: none;
            display: inline-block;
            font-size: 16px;
            margin-top: 10px;
            box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
        }
        .gysSave:hover {
            cursor:pointer
        }
        .layui-form-label {
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
        }
    </style>
</head>
<body>
<form id="form1" class="layui-form layui-form-pane" action="" style="width: 100%;height: 100%;padding: 15px;">
    <div class="layui-form-item" id="simplewizardinwidget-steps">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top:1px;">
            <legend>主信息</legend>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">货品编号</label>
                    <div class="layui-input-inline">
                        <input type="text" name="bh" id="bh" lay-verify="required" jq-verify="required" jq-verify="required" autocomplete="off" placeholder="请输入货品编号" class="layui-input" style="width: 189px">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" data-title>货品名称</label>
                    <div class="layui-input-inline">
                        <input type="text" name="mc" id="mc" data-required autocomplete="off" placeholder="请输入货品名称" jq-verify="required"  lay-verify="required" class="layui-input" >
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" data-title>物料清单</label>
                    <div class="layui-input-inline">
                        <select name="bom" lay-filter="bom" style="width: 163px">
                            <option value="0">不存在</option>
                            <option value="1">存在</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">货品种类</label>
                    <div class="layui-input-inline">
                        <select lay-ignore="lay-ignore" class="js-data-example-ajax" jq-verify="required" select2 name="goodszlid" id="zlid" style="width: 193px"></select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" data-title>货品条码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="tm" id="tm" data-required autocomplete="off" placeholder="请输入货品条码" jq-verify="required" lay-verify="required" class="layui-input" >
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">包装</label>
                    <div class="layui-input-inline">
                        <input type="text" name="bzmc"  readonly  data-required autocomplete="off" onchange="bzChange()" placeholder="请输入包装" jq-verify="required" lay-verify="required"  class="layui-input" >
                        <input type="hidden" name="bzid" >
                        <!--  <select lay-ignore="lay-ignore" class="js-data-example-ajax" jq-verify="required" name="zlid" style="width: 193px"></select>-->
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" data-title title="是否可以销售">是否可以销售</label>
                    <div class="layui-input-inline">
                        <select name="bkxs" lay-filter="bkxs" jq-verify="required" style="width: 163px">
                            <option value="0">不可销售</option>
                            <option value="1">可以销售</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" title="是否采集SN码">是否采集SN码</label>
                    <div class="layui-input-inline">
                        <select name="cjsn" lay-filter="cjsn"  jq-verify="required"style="width: 163px">
                            <option value="0">不采集SN码</option>
                            <option value="1">采集SN码</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">是否有配件</label>
                    <div class="layui-input-inline">
                        <select name="zhhp" id="zhhp" lay-filter="zhhp" jq-verify="required" style="width: 163px">
                            <option value="1">是</option>
                            <option value="0">否</option>
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" data-title title="库存数量最大预警">库存数量最大预警</label>
                    <div class="layui-input-inline">
                        <input type="text" name="kczdl" id="kczdl" data-required autocomplete="off"  jq-verify="required"  lay-verify="required|zhengshu" placeholder="请输入最大预警"  class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" data-title title="库存数量最小预警">库存数量最小预警</label>
                    <div class="layui-input-inline">
                        <input type="text" name="kczxl" id="kczxl" data-required autocomplete="off" jq-verify="required"  lay-verify="required|zhengshu" placeholder="请输入最小预警"  class="layui-input">
                    </div>
                </div>
                <div class="layui-inline" id="zjgzDiv">
                    <label class="layui-form-label">质检规则</label>
                    <div class="layui-input-inline">
                        <select lay-ignore="lay-ignore" class="js-data-example-ajax_zjgzid" jq-verify="required" select2 name="zjgzids" style="width: 193px"></select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" data-title>NC编码</label>
                    <div class="layui-input-inline">
                        <input type="text" name="nc" id="nc" autocomplete="off" placeholder="请输入NC编码"  class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label" data-title>规格</label>
                    <div class="layui-input-inline">
                        <input type="text" name="gg" id="gg"  autocomplete="off" placeholder="请输入规格"  class="layui-input">
                    </div>
                </div>
            </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top:1px;">
            <legend>有效期</legend>
            <div class="layui-inline">
                <label class="layui-form-label" data-title>有效期控制</label>
                <div class="layui-input-inline">
                    <select name="yxqkz" id="yxqkz" lay-filter="yxqkz" style="width: 163px">
                        <option value="0">不启用</option>
                        <option value="1">启用</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline" id="zqlxDiv">
                <label class="layui-form-label" data-title>周期类型</label>
                <div class="layui-input-inline">
                    <select name="zqlx" lay-filter="zqlx" style="width: 163px">
                        <option value="0">生产日期</option>
                        <option value="1">入库日期</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline" id="yxqDiv">
                <label class="layui-form-label">有效期</label>
                <div class="layui-input-inline">
                    <input type="number" name="yxq" id="yxq" lay-verify="required|zhengshu" autocomplete="off" placeholder="请输入有效期" class="layui-input" style="width: 189px">
                </div>
            </div>
            <div class="layui-inline" id="sxqyjDiv">
                <label class="layui-form-label">失效期预警</label>
                <div class="layui-input-inline">
                    <input type="number" name="sxqyj" id="sxqyj" lay-verify="required|zhengshu" autocomplete="off" placeholder="请输入失效期预警" class="layui-input" style="width: 189px">
                </div>
            </div>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top:1px;">
            <legend>补货策略</legend>
            <div class="layui-inline">
                <label class="layui-form-label">补货上限</label>
                <div class="layui-input-inline">
                    <input type="text" name="bhsx" id="bhsx" lay-verify="required|zhengshu" autocomplete="off" placeholder="请输入补货上限" class="layui-input" style="width: 189px">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" data-title>存储区补货</label>
                <div class="layui-input-inline">
                    <select name="ccqbh" lay-filter="ccqbh" style="width: 163px">
                        <option value="0">是</option>
                        <option value="1">否</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" data-title>补货单位</label>
                <div class="layui-input-inline">
                    <select name="bhdw"  id="bhdw" lay-filter="bhdw" style="width: 163px">
                        <option value="0">实数补货</option>
                        <option value="1">取整补货</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" data-title title="从箱捡区补货">从箱捡区补货</label>
                <div class="layui-input-inline">
                    <select name="xjhwbh" lay-filter="xjhwbh" style="width: 163px">
                        <option value="0">否</option>
                        <option value="1">是</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label" data-title>取整方式</label>
                <!--<div class="layui-input-inline" id="qzfsDiv1">
                    <select  id="qzfs1" lay-filter="qzfs" style="width: 163px">
                        <option value="0">初始</option>
                    </select>
                </div>-->
                <div class="layui-input-inline"  >
                    <select  id="qzfs" name="qzfs" lay-filter="qzfs" style="width: 163px">
                        <option value="0">初始</option>
                        <option value="1">向上</option>
                        <option value="2">向下</option>
                    </select>
                </div>
            </div>
            <legend>拣货位</legend>
            <div class="layui-collapse" lay-filter="test">
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">主单位</h2>
                    <div class="layui-colla-content" style="float: left;">
                        <label  data-title>数量</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="zdwsl" id="zdwsl" lay-verify="required" readonly autocomplete="off" placeholder="请输入数量"  class="layui-input" style="width: 189px;background-color: #f2f2f2;">
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" style="float: left">
                        <label  data-title>包装描述</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="zdwms" id="zdwms" lay-verify="required" readonly autocomplete="off" placeholder="请输入包装描述"   class="layui-input" style="width: 189px;background-color: #f2f2f2;">
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" id="jhwzlxDiv">
                        <label  data-title>主单位库位使用类型 </label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="jhwzlx" lay-filter="jhwzlx"  id="jhwzlx" style="width: 163px">
                                    <option value="0">存储库位</option>
                                    <option value="1">件拣货位</option>
                                    <option value="3">箱件拣货位</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" >
                        <div id="zkwidDiv"style="display: none">
                            <label  data-title>主单位库位</label>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="js-data-example-ajax_bzid" select2 name="zkwids" id="zkwid" jq-verify="required" lay-verify="required" style="width: 193px"></select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">内包装</h2>
                    <div class="layui-colla-content" style="float: left;">
                        <label  data-title>数量</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="nbzsl" id="nbzsl" lay-verify="required"  readonly autocomplete="off" placeholder="请输入数量" value="1" class="layui-input" style="width: 189px;background-color: #f2f2f2;">
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" style="float: left">
                        <label  data-title>包装描述</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="nbzms" id="nbzms" lay-verify="required" readonly  autocomplete="off" placeholder="请输入包装描述"  class="layui-input" style="width: 189px;background-color: #f2f2f2;">
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" id="jhwnlxDiv">
                        <label  data-title>内包装库位使用类型</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="jhwnlx" lay-filter="jhwnlx"  id="jhwnlx" style="width: 163px">
                                    <option value="0">存储库位</option>
                                    <option value="1">件拣货位</option>
                                    <option value="3">箱件拣货位</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" >
                        <div id="nkwidDiv"style="display: none">
                            <label  data-title>内包装库位</label>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="js-data-example-ajax_bzid" select2 name="nkwids" id="nkwid" jq-verify="required" lay-verify="required" style="width: 193px"></select>

                                    <!--  <input type="text" name="nkwid" id="nkwid" lay-verify="required"  autocomplete="off" placeholder="请选择库位"  class="layui-input" style="width: 189px">-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-colla-item">
                    <h2 class="layui-colla-title">箱</h2>
                    <div class="layui-colla-content" style="float: left;">
                        <label  data-title>数量</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="xsl" id="xsl" lay-verify="required" readonly autocomplete="off" placeholder="请输入数量"  class="layui-input" style="width: 189px;background-color: #f2f2f2;">
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" style="float: left">
                        <label  data-title>包装描述</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <input type="text" name="xms" id="xms" lay-verify="required" readonly autocomplete="off" placeholder="请输入包装描述" value="1" class="layui-input" style="width: 189px;background-color: #f2f2f2;">
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" id="jhxnlxDiv">
                        <label  data-title>箱包装库位使用类型</label>
                        <div class="layui-inline">
                            <div class="layui-input-inline">
                                <select name="jhxnlx" lay-filter="jhxnlx"  id="jhxnlx" style="width: 163px">
                                    <option value="0">存储库位</option>
                                    <option value="2">箱拣货位</option>
                                    <option value="3">箱件拣货位</option>
                                </select>
                                <!-- <input type="text" name="jhxnlx" id="jhxnlx" lay-verify="required" autocomplete="off" placeholder="请输入库位类型" value="1" class="layui-input" style="width: 189px"> -->
                            </div>
                        </div>
                    </div>
                    <div class="layui-colla-content" >
                        <div id="xkwidDiv"style="display: none">
                            <label  data-title>箱包装库位</label>
                            <div class="layui-inline">
                                <div class="layui-input-inline">
                                    <select lay-ignore="lay-ignore" class="js-data-example-ajax_bzid" select2 name="xkwids" id="xkwid" jq-verify="required" lay-verify="required" style="width: 193px"></select>

                                    <!--  <input type="text" name="xkwid" id="xkwid" lay-verify="required" autocomplete="off" placeholder="请选择库位"  class="layui-input" style="width: 189px">-->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>
        <!-- <fieldset class="layui-field-title" style="margin-top:1px;">
             <div class="layui-inline">
                 <label class="layui-form-label" data-title>取整方式</label>
                 <div class="layui-input-inline">
                     <select name="goods_type" lay-filter="qzfs" style="width: 163px">
                         <option value="0">向下</option>
                         <option value="1">初始</option>
                         <option value="2">向上</option>
                     </select>
                 </div>
             </div>
         </fieldset>-->
        <fieldset class="layui-elem-field layui-field-title" style="margin-top:1px;">
            <legend>供应商</legend>
            <div class="layui-inline">
                <label class="layui-form-label">供应商</label>
                <div class="layui-input-inline">
                    <select lay-ignore="lay-ignore" class="js-data-example-gysid" name="gysid" id="gysid" style="width: 193px"></select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">优先级</label>
                <div class="layui-input-inline">
                    <input type="number" name="yxj" id="yxj" value="1" min="1" lay-verify="required" autocomplete="off" placeholder="优先级" class="layui-input" style="width: 189px">
                </div>
            </div>
            <div class="layui-inline">
                <label>激活</label>
                <div class="layui-inline">
                    <input type="checkbox" checked="" name="close" lay-skin="switch"   id="jh" lay-filter="switchTest" lay-text="ON|OFF">
                </div>
            </div>
            <div class="layui-inline">
                <label>可用操作</label>
                <div class="layui-inline" id="gysSaveDiv">
                    <p id="gysSave" class="gysSave">保存</p>
                </div>
                <div class="layui-inline" id="gysEditDiv" style="display: none">
                    <p id="cancel"  class="gysSave" style="float: right;background: white;color: black;    margin-left: 10px;">取消</p>
                    <p id="gysEdit" class="gysSave"  style="float: right;" >编辑</p>
                </div>
            </div>
            <!--列表-->
            <section class="panel panel-padding layui-card-body">
                <div class="pro">
                    <table id="table"></table>
                </div>
            </section>
        </fieldset>
        <fieldset class="layui-elem-field layui-field-title" style="margin-top:1px;" id="pjDiv" >
            <legend>配件</legend>
            <div class="layui-inline">
                <label class="layui-form-label">货品编号</label>
                <div class="layui-input-inline">
                    <select lay-ignore="lay-ignore" class="js-data-example-hpid" name="hpid" id="hpid" style="width: 193px"></select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">数量</label>
                <div class="layui-input-inline">
                    <input type="number" name="sl" id="sl" value="1"  min="1" lay-verify="required" autocomplete="off" placeholder="数量"  class="layui-input" style="width: 189px">
                </div>
            </div>
            <div class="layui-inline">
                <label>配件保存</label>
                <div class="layui-inline">
                    <p id="pjSave" class="gysSave">保存</p>
                    <!--  <button class="layui-btn layui-btn-radius layui-btn-sm" style="background: dodgerblue">保存</button>-->
                </div>
            </div>
            <!--列表-->
            <section class="panel panel-padding layui-card-body">
                <div class="pro">
                    <table id="tableParts"></table>
                </div>
            </section>
        </fieldset>
    </div>
    <input type="hidden" th:value="${id}" name="id" id="id">
    <div class="layui-form-item" style="float: right">
        <div class="layui-input-block">
            <button class="layui-btn" jq-filter="submit"  lay-submit="" lay-filter="addSave">保存</button>
            </button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <input type="hidden" id="zjfs" th:value="${zjfs}">
</form>
</body>
<div th:include="public/public_js::public_js"></div>
<script th:src="@{/plugin/beyond/assets/js/fuelux/wizard/wizard-custom.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layui/js/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/plugin/layui/js/version.js}"></script>
<script th:src="@{/plugin/layui/js/common.js}"></script>


<script>

    $(function () {
        console.info("32332")
        console.log("我来了！！ ");
        /*$.ajax({
         type : "get",
         url:"/wmsgoods/getWmsGoods/"+$("#id").val(),
         success:function (data) {
         zzpUtils.loadJsonDataToForm(data.data);
         //控制库位是否显示
         if(data.data.jhwzlx==0){//主单位存储库位
         $("#zkwidDiv").hide();
         $("#jhwzlxDiv").css("float","none");
         }else if(data.data.jhwzlx==1||data.data.jhwzlx==3){//主单位件拣货位或箱件拣货位
         $("#zkwidDiv").show();
         $("#jhwzlxDiv").css("float","left");
         $("#zkwidDiv").css('pointer-events','none');
         $("#jhwzlxDiv").css('pointer-events','none');
         }
         if(data.data.jhwnlx==0){//内包装存储库位
         $("#nkwidDiv").hide()
         $("#jhwnlxDiv").css("float","none");
         $("#nkwid").css('background','black');
         $("#nkwidDiv").css('pointer-events','none');
         $("#jhwnlxDiv").css('pointer-events','none');

         }else if(data.data.jhwnlx==1||data.data.jhwnlx==3){//内包装件拣货位或箱件拣货位
         $("#nkwidDiv").show();
         $("#jhwnlxDiv").css("float", "left");
         $("#nkwidDiv").css('pointer-events','none');
         $("#jhwnlxDiv").css('pointer-events','none');
         }
         if(data.data.jhxnlx==0){//箱存储库位
         $("#xkwidDiv").hide()
         $("#jhxnlxDiv").css("float","none");
         $("#xkwidDiv").css('pointer-events','none');
         $("#jhxnlxDiv").css('pointer-events','none');

         }else if(data.data.jhxnlx==2||data.data.jhxnlx==3){//箱 箱拣货位或箱件拣货位
         $("#xkwidDiv").show();
         $("#jhxnlxDiv").css("float", "left");
         $("#xkwidDiv").css('pointer-events','none');
         $("#jhxnlxDiv").css('pointer-events','none');
         }
         if(data.data.zhhp==0){//没有配件
         $("#pjdiv").hide();
         }else if(data.data.zhhp==1){
         $("#pjdiv").show();

         }


         },error: function (xhr, textStatus) {
         console.log(textStatus);
         console.log(xhr)
         }
         });*/


    });

    layui.use(['myform','zzpUtils','form','jquery', 'list', 'layer'],function () {
        var form = layui.form,
            zzpUtils = layui.zzpUtils,
            $ = layui.jquery;
        // 判断是否显示质检规则
        if($("#zjfs").val()==0){
            $("#zjgzDiv").hide();
        }else if($("#zjfs").val()==1){
            $("#zjgzDiv").show();
        }

        form.verify({
            zhengshu: function (value) {
                var result = zhengshu(value);
                if (result != "Y") {
                    return result;
                }
            }
        });
        function zhengshu(value) {
            /*var reg = /^\+?((0|([1-9]+\d*))|((0\.\d+)|([1-9]+\d*\.\d+)))$/;*/
            var reg =  /^([1-9]\d*|[0]{1,1})$/;//bao
            if (reg.test(value)) {
                return "Y";
            }
            return "请输入正整数";
        }

        zzpUtils.action({
            url:"/wmsgoods/getWmsGoods/"+$("#id").val(),
            type:"get",
            success:function (data) {
                zzpUtils.loadJsonDataToForm(data.data);
                if(data.data.zhhp==1){//是
                    $("#pjDiv").show();
                }else if(data.data.zhhp==0){
                    $("#pjDiv").hide();
                }
                if(data.data.bhdw==0) {//实数补货
                    $("#qzfs option").each(function () {
                        console.info($(this));
                        console.info($(this).val());
                        if ($(this).val() != 0) {
                            $(this).attr("disabled", "");
                        }else{
                            $(this).removeAttr("disabled")
                        }

                    })
                    $("#qzfs").val("0");//给默认值为”初始“
                    form.render();

                }else if(data.data.bhdw==1){//取整补货
                    $("#qzfs option").each(function () {
                        console.info($(this));
                        console.info($(this).val());
                        if ($(this).val() == 0) {
                            $(this).attr("disabled", "");
                        }else{
                            $(this).removeAttr("disabled")
                        }
                    })
               /*     $("#qzfs").val("1");//给默认值为”向上“*/
                    form.render();
                }
                if(data.data.yxqkz==0){//有效期控制 不启用
                    $("#sxqyjDiv").hide();
                    $("#yxqDiv").hide();
                    $("#zqlxDiv").hide();
                }else if(data.data.yxqkz==1){//启用
                    $("#sxqyjDiv").show();
                    $("#yxqDiv").show();
                    $("#zqlxDiv").show();
                }
                //控制库位是否显示
                if(data.data.jhwzlx==0){//主单位存储库位
                    $("#zkwidDiv").hide();
                    $("#jhwzlxDiv").css("float","none");
                }else if(data.data.jhwzlx==1||data.data.jhwzlx==3){//主单位件拣货位或箱件拣货位
                    $("#zkwidDiv").show();
                    $("#jhwzlxDiv").css("float","left");
                    $("#zkwidDiv").css('pointer-events','none');
                    $("#jhwzlxDiv").css('pointer-events','none');
                }
                if(data.data.jhwnlx==0){//内包装存储库位
                    $("#nkwidDiv").hide()
                    $("#jhwnlxDiv").css("float","none");
                  /*  $("#nkwid").css('background','black');
                    $("#nkwidDiv").css('pointer-events','none');
                    $("#jhwnlxDiv").css('pointer-events','none');*/

                }else if(data.data.jhwnlx==1||data.data.jhwnlx==3){//内包装件拣货位或箱件拣货位
                    $("#nkwidDiv").show();
                    $("#jhwnlxDiv").css("float", "left");
                    $("#nkwidDiv").css('pointer-events','none');
                    $("#jhwnlxDiv").css('pointer-events','none');
                }
                if(data.data.jhxnlx==0){//箱存储库位
                    $("#xkwidDiv").hide()
                    $("#jhxnlxDiv").css("float","none");
                   /* $("#xkwidDiv").css('pointer-events','none');
                    $("#jhxnlxDiv").css('pointer-events','none');*/

                }else if(data.data.jhxnlx==2||data.data.jhxnlx==3){//箱 箱拣货位或箱件拣货位
                    $("#xkwidDiv").show();
                    $("#jhxnlxDiv").css("float", "left");
                    $("#xkwidDiv").css('pointer-events','none');
                    $("#jhxnlxDiv").css('pointer-events','none');
                }
            },error: function (xhr, textStatus) {
                console.log(textStatus);
                console.log(xhr)
            }
        });
        var editIndex;
        window.operateEvent = {
            "click #deleteBtns":function (e, value, row, index) {//删除供应商
                var tabledata = $table.bootstrapTable('getData');
                console.info("index:"+index);
                console.info(row);
                var gysids = [];
                gysids.push(row.gysid);
                $table.bootstrapTable('remove', {field: 'gysid', values: gysids});
                $table.bootstrapTable('load', tabledata);
                var rows=$table.bootstrapTable('getData');
                for(var i=index;i<rows.length;i++){
                    rows[i].yxj=Number( rows[i].yxj)-Number(1);
                    $table.bootstrapTable('updateRow',{index: i, row: rows[i]});
                }
                //获取最大优先级
                var yxj=rows[0].yxj;//假设最大值为rows[0]
                for(var i=1;i<rows.length;i++){
                    curYxj=rows[i].yxj
                    curYxj > yxj ? yxj= curYxj : null
                }
                $("#yxj").val(Number(yxj)+Number(1));
                $("#yxj").attr('max',Number(yxj)+Number(1));
            },
            "click .editBtn":function (e, value, row, index) {//编辑供应商
                editIndex=index;
                $("#gysEditDiv").show();
                $("#gysSaveDiv").hide();
                $("#yxj").val(row.yxj);
                $("#gysid").append(new Option(row.mc, row.bh+','+row.gysid, false, true));
            },
            "click .pjDelete":function (e, value, row, index) {//删除配件
                var tabledata = $tableParts.bootstrapTable('getData');
                var hpids = [];
                hpids.push(row.hpid);
                $tableParts.bootstrapTable('remove', {field: 'hpid', values: hpids});
                $tableParts.bootstrapTable('load', tabledata);
            },
            "change .slnumbers":function (e, value, row, index) {//删除配件
                var reg=/^[1-9]{1,}[\d]*$/;
                if(!$("#sl"+row.hpid).val().match(reg)){
                    layer.msg("请输入正整数！");
                    $("#sl"+row.hpid).val("1");
                }else{
                    row.sl=$("#sl"+row.hpid).val();
                    $tableParts.bootstrapTable('updateRow', {index:index,row:row});
                }
            },

        };
        //是否有配件
        form.on('select(zhhp)', function(data){
            if($("#zhhp").val()==1){//是
                $("#pjDiv").show();
            }else if($("#zhhp").val()==0){
                $("#pjDiv").hide();
            }
        });
        //补货单位更改
        form.on('select(bhdw)', function(data){
            console.info($("#qzfs option"));
            if($("#bhdw").val()==0) {//实数补货
                $("#qzfs option").each(function () {
                    console.info($(this));
                    console.info($(this).val());
                    $(this).attr("disabled", "");
                    if ($(this).val() != 0) {
                        $(this).attr("disabled", "");
                    }else{
                        $(this).removeAttr("disabled")
                    }
                })
                $("#qzfs").val("0");//给默认值为”初始“
            }else if($("#bhdw").val()==1){//取整补货
                $("#qzfs option").each(function () {
                    console.info($(this));
                    console.info($(this).val());
                    $(this).attr("disabled", "");
                    if ($(this).val() == 0) {
                        $(this).attr("disabled", "");
                    }else{
                        $(this).removeAttr("disabled")
                    }
                })
                $("#qzfs").val("1");//给默认值为”向上“
            }
            form.render();
            /*if($("#bhdw").val()==0){//实数补货
                $("#qzfsDiv1").show();
                $("#qzfsDiv2").hide();
            }else if($("#bhdw").val()==1){//取整补货
                $("#qzfsDiv1").hide();
                $("#qzfsDiv2").show();
            }*/
        });
        //选中包装
        /* form.on('select(bzid)', function(data){
         alert("dfds");
         });
         */        //更改包装名称时获取包装明细
        window.bzChange=function(){
            var id=$("#bzid").val();
            $.ajax({
                type: "GET" ,
                url: "/zxsdwms/wmspacking/getWmsPacking/" +id,
                dataType: "JSON",
                async: false,
                success: function (data) {
                    console.info(data);
                    console.info(data.list);
                    var arr=data.list;
                    for(var i=0;i<arr.length;i++){
                        if(arr[i].bzlx==0){//主单位
                            $("#zdwsl").val(arr[i].zdwsl);
                            $("#zdwms").val(arr[i].ms);
                        }else if(arr[i].bzlx==1){//内包装
                            $("#nbzsl").val(arr[i].zdwsl);
                            $("#nbzms").val(arr[i].ms);
                        }else if(arr[i].bzlx==2){//箱
                            $("#xsl").val(arr[i].zdwsl);
                            $("#xms").val(arr[i].ms);
                        }
                    }
                },
                error: function () { alert("Error"); }
            });
        }
        //有效期控制更改时
        form.on('select(yxqkz)', function(data){
            if($("#yxqkz").val()==0){//不启用
                $("#sxqyjDiv").hide();
                $("#yxqDiv").hide();
                $("#zqlxDiv").hide();
            }else if($("#yxqkz").val()==1){//启用
                $("#sxqyjDiv").show();
                $("#yxqDiv").show();
                $("#zqlxDiv").show();
            }
        })
        //主单位库位类型更改时
        form.on('select(jhwzlx)', function(data){
            var map={"lx":$("#jhwzlx").val()};
            if($("#jhwzlx").val()==0){//存储库位
                $("#zkwidDiv").hide()
                $("#jhwzlxDiv").css("float","none");
            }else{//件拣货位或箱件拣货位
                $("#zkwidDiv").show();
                $("#jhwzlxDiv").css("float","left");
                $('#zkwid').select2({
                    ajax: {
                        url: "/zxsdwms/wmslibraryposition/getZCLibrarysBymc",
                        data:  JSON.stringify(map),
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                lx:$("#jhwzlx").val(),
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            console.info(data);
                            var arr= [];
                            if(data){
                                for (var i=0;i<data.rows.length;i++){
                                    arr.push({id: data.rows[i].id,text:data.rows[i].mc});
                                }
                            }
                            console.log(arr);
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入库位',
                    allowClear: true
                });
            }

        });
        //内包装库位类型更改时
        form.on('select(jhwnlx)', function(data){
            var map={"lx":$("#jhwnlx").val()};
            if($("#jhwnlx").val()==0){//存储库位
                $("#nkwidDiv").hide()
                $("#jhwnlxDiv").css("float","none");
            }else {//件拣货位或箱件拣货位
                $("#nkwidDiv").show();
                $("#jhwnlxDiv").css("float", "left");
                $('#nkwid').select2({
                    ajax: {
                        url: "/zxsdwms/wmslibraryposition/getZCLibrarysBymc",
                        data: JSON.stringify(map),
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                lx:$("#jhwnlx").val(),
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            var arr = [];
                            if (data) {
                                for (var i = 0; i < data.rows.length; i++) {
                                    arr.push({id: data.rows[i].id,text:data.rows[i].mc});
                                }
                            }
                            console.log(arr);
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入库位',
                    allowClear: true
                });
            }

        });

        //箱库位类型更改时
        form.on('select(jhxnlx)', function(data){
            var map={"lx":$("#jhxnlx").val()};
            if($("#jhxnlx").val()==0){//存储库位
                $("#xkwidDiv").hide()
                $("#jhxnlxDiv").css("float","none");
            }else {//件拣货位或箱件拣货位
                $("#xkwidDiv").show();
                $("#jhxnlxDiv").css("float", "left");
                $('#xkwid').select2({
                    ajax: {
                        url: "/zxsdwms/wmslibraryposition/getZCLibrarysBymc",
                        data: JSON.stringify(map),
                        type: 'POST',
                        contentType: "application/json",
                        data: function (params) {
                            var query = {
                                lx:$("#jhxnlx").val(),
                                mc: params.term
                            };
                            return JSON.stringify(query);
                        },
                        processResults: function (data) {
                            var arr = [];
                            if (data) {
                                for (var i = 0; i < data.rows.length; i++) {
                                    arr.push({id: data.rows[i].id,text:data.rows[i].mc});
                                }
                            }
                            console.log(arr);
                            return {
                                results: arr
                            };
                        },
                        cache: true
                    },
                    language: "zh-CN",
                    placeholder: '请输入库位',
                    allowClear: true
                });
            }

        });
        //供应商
        function operateFormatter(value, row, index) {
            console.log(123456789);
            return [
                '<a class="layui-btn layui-btn-xs editBtn">编辑</a>',
                '<a class="layui-btn layui-btn-danger layui-btn-xs " id="deleteBtns">删除</a>'
            ].join('')
        }
        // 查货品种类
        $('.js-data-example-ajax').select2({
            ajax: {
                url: '/zxsdwms/wmsgoodstype/getWmsGoodsTypeByHzId',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        for (var i=0;i<data.length;i++){
                            arr.push({id:data[i].id,text:data[i].mc});
                        }
                    }
                    console.log(arr);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询货品种类',
            allowClear: true
        });
        // 包装
        $('.js-data-example-ajax_bzid').select2({
            ajax: {
                url: '/zxsdwms/wmspacking/getWmsPackingBySshzid',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= [];
                    if(data){
                        for (var i=0;i<data.rows.length;i++){
                            arr.push({id:data.rows[i].id,text:data.rows[i].bzmc});
                        }
                    }
//                        console.log('arr', arr);
//                        console.log('data', data);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询包装',
            allowClear: true
        });
        //质检规则
        $('.js-data-example-ajax_zjgzid').select2({
            ajax: {
                url: '/zxsdwms/wmsqualitytesting/selectZjgzBymc',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        for (var i=0;i<data.length;i++){
                            arr.push({id:data[i].id,text:data[i].mc});
                        }
                    }
                    console.log(arr);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询抽检规则',
            allowClear: true
        });
        //拣货位
        $('.js-data-example-ajax_j').select2({
            ajax: {
                url: '/zxsdwms/wmslibraryposition/getLibrarysBymc',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        for (var i=0;i<data.length;i++){
                            arr.push({id:data[i].mc,text:data[i].mc});
                        }
                    }
                    console.log(arr);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入拣货位',
            allowClear: true
        });
        // 供应商
        var two, scc;
        $('.js-data-example-gysid').select2({
            ajax: {
                url: '/zxsdwms/wmsownersupplier/getWmsOwnerSupplierByHzId',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        mc: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= new Array();
                    if(data){
                        scc = data;
                        for (var i=0;i<data.rows.length;i++){
                            two = data.rows[i].bh.toString() + ',' + data.rows[i].id.toString();
                            arr.push({id:two,text:data.rows[i].mc});
                        }
                    }
                    console.log(arr);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入供应商',
            allowClear: true
        });
        // 货品编号
        $('.js-data-example-hpid').select2({
            ajax: {
                url: '/zxsdwms/wmsgoods/getGoodsBySshzid',
                dataType: 'json',
                type: 'POST',
                contentType: "application/json",
                data: function (params) {
                    var query = {
                        bh: params.term
                    };
                    return JSON.stringify(query);
                },
                processResults: function (data) {
                    var arr= [];
                    if(data){
                        for (var i=0;i<data.rows.length;i++){
                            arr.push({id:data.rows[i].id+','+data.rows[i].mc+','+data.rows[i].hzmc,text:data.rows[i].bh});
                        }
                    }
                    console.log(arr);
                    return {
                        results: arr
                    };
                },
                cache: true
            },
            language: "zh-CN",
            placeholder: '请输入查询货品编号',
            allowClear: true
        });
        // 供应商列表
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            showColumns: false,  // 右上角选择字段
            pagination:false,  // 分页
            /* url: '[{}]',*/
            url: '/wmsgoods/getSuppliersByHpid/'+$("#id").val(),
            method:'get',
            columns: [/*{
                field: '',
                checkbox: true
            },*/{
                field: 'gysid',
                title: '供应商id',
                visible:false
            },{
                field: 'yxj',
                title: '优先级'
            },{
                field: 'bh',
                title: '编号'
            },{
                field: 'mc',
                title: '名称'
            },{
                field: 'sfjh',
                title: '激活',
                /*formatter:function (value, row, index) {
                 if(row.sfyx==0){
                 return '未激活';
                 }else if(row.sfyx==1){
                 return '激活';
                 }
                 }*/
            },{
                field:'caozuo',
                title: '操作',
                events:operateEvent,
                formatter:operateFormatter
            }],
            /* queryParams: function () {//查询条件
             return {"id":$("#id").val()};
             }, */
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });

        $("#yxj").on('input propertychange',function (data) {
            var rows= $table.bootstrapTable('getData');
            $("#yxj").val(Number(rows.length)+Number(1));
        })
        // 供应商保存
        $('#gysSave').click(function () {
            var gyg;
            var reg=/^[1-9]{1,}[\d]*$/;//不含0的正整数
            if(!$("#yxj").val().match(reg)){
                layer.msg("优先级请输入正整数");
            }else {
            if($('#gysid').val()==null||$('#gysid').val()==""){
                layer.msg("供应商不可为空");
            }else{
                var yxj = $('#yxj').val();
                var strs= $('#gysid').val().split(",");
                var rows= $table.bootstrapTable('getData');
                var flag=true;
                for(var i=0;i<rows.length;i++){
                    console.info(rows[i].gysid)
                    if(rows[i].gysid==strs[1]){
                        flag=false;
                    }
                }
                if(flag==true){
                    console.log('编号' , strs[0]);
                    scc.rows.forEach((item) => {
                        if (item.bh === strs[0]) {
                        gyg = item.mc;
                    }
                })
                    //控制优先级的正常顺序，即便输入框被改变保存的时候也强制转换成正常顺序
                    var rows=$table.bootstrapTable('getData');
                    if (rows.length > 0) {
                        var maxyxj = rows[0].yxj;//假设最大值为rows[0]
                        for (var i = 1; i < rows.length; i++) {
                            curYxj = rows[i].yxj
                            curYxj > maxyxj ? maxyxj = curYxj : null
                        }
                        if (yxj <= maxyxj) {
                            $("#yxj").val(Number(maxyxj) + Number(1));
                        }
                    }

                    var json = {"gysid":strs[1],"yxj": $('#yxj').val(), "mc": gyg, "bh":strs[0]};
                    if (tmp == 1) {
                        console.log('激活');
                        json['sfjh'] = '激活';
                        json['sfyx'] = '1';
                    } else {
                        json['sfjh'] = '未激活';
                        console.log('未激活');
                        json['sfyx'] = '0';
                    }

                    $('#gysid').select2('val','all');
                    $("#yxj").val(Number($("#yxj").val())+Number(1));
                    $("#yxj").attr('max',Number(yxj)+Number(1));
                    $table.bootstrapTable('append', json);

//                console.log('tmp', tmp);
                }else {
                    layer.msg("供应商已存在");
                }
            }
            }
        });

        // 供应商修改
        $('#gysEdit').click(function () {
            var gyg;
            var reg=/^[1-9]{1,}[\d]*$/;//不含0的正整数
            if(!$("#yxj").val().match(reg)){
                layer.msg("优先级请输入正整数");
            }else {
            if($('#gysid').val()==null||$('#gysid').val()==""){
                layer.msg("供应商不可为空");
            }else{
                var yxj = $('#yxj').val();
                var strs= $('#gysid').val().split(",");
                var rows= $table.bootstrapTable('getData');
                var flag=true;
                console.info("strs");
                console.info(strs);
                for(var i=0;i<rows.length;i++){
                    console.info(rows[i].gysid);
                    if(rows[i].gysid==strs[1]){
                        flag=false;
                    }
                }
                if(flag==true){
                    console.log('编号' , strs[0]);
                    scc.rows.forEach((item) => {
                        if (item.bh === strs[0]) {
                        gyg = item.mc;
                    }
                })
                    var json = {"gysid":strs[1],"yxj": $('#yxj').val(), "mc": gyg, "bh":strs[0]};
                    console.log('名称',gyg);
                    console.log('优先级',yxj);
                    if (tmp == 1) {
                        console.log('激活');
                        json['sfjh'] = '激活';
                    } else {
                        json['sfjh'] = '未激活';
                        console.log('未激活');
                    }
                    $('#gysid').select2('val','all');
                    console.info("data");

                    var rows=$table.bootstrapTable('getData');
                    //获取最大优先级
                    var yxj=rows[0].yxj;//假设最大值为rows[0]
                    for(var i=1;i<rows.length;i++){
                        curYxj=rows[i].yxj
                        curYxj > yxj ? yxj= curYxj : null
                    }
                    $("#yxj").val(Number(yxj)+Number(1));
                    /*    $("#yxj").val(Number($("#yxj").val())+Number(1));*/
                    $table.bootstrapTable('updateRow', {index: editIndex, row: json});
                    $("#gysSaveDiv").show();
                    $("#gysEditDiv").hide();
//                console.log('tmp', tmp);
                }else {
                    layer.msg("供应商已存在");
                }
            }
            }
        });
        //供应商修改取消
        $('#cancel').click(function () {
            $('#gysid').select2('val','all');
            var rows=$table.bootstrapTable('getData');
            //获取最大优先级
            var yxj=rows[0].yxj;//假设最大值为rows[0]
            for(var i=1;i<rows.length;i++){
                curYxj=rows[i].yxj
                curYxj > yxj ? yxj= curYxj : null
            }
            $("#yxj").val(Number(yxj)+Number(1));
            $("#gysSaveDiv").show();
            $("#gysEditDiv").hide();
        });

        var tmp = 1;
        // 是否激活开关
        form.on('switch(switchTest)', function(data){
//                    console.log('开关checked：', (this.checked ? 'true' : 'false'));
            console.log('开关checked：', data.elem.checked);
            var type = data.elem.checked;
            if (type) {
                tmp = 1;
            } else {
                tmp = 0;
            }
        });
        // 配件>列表
        var $tableParts = zzpUtils.table({
            elem: '#tableParts',
            isApi: true,
            showColumns: false,
            pagination:false,
            url: '/wmsgoods/getAccessoriesByHpid/'+$("#id").val(),
            method:'get',
            columns: [/*{
                field: '',
                checkbox: true
            },*/{
                field: 'hpid',
                title: '货品id',
                visible:false
            },{
                field: 'hzmc',
                title: '货主名称'
            },{
                field: 'bh',
                title: '货品编号'
            },{
                field: 'sl',
                title: '数量',
                formatter:operateFormatterNumber,
                events:operateEvent
            },{
                field: 'mc',
                title: '货品名称'
            },{
                field:'caozuo',
                title: '操作',
                events:operateEvent,
                formatter:operateFormatter2
            }],
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            }
        });
        //配件
        function operateFormatter2(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-danger layui-btn-xs pjDelete" >删除</a>'
            ].join('')
        }
        function operateFormatterNumber (value,row,index) {
            return [
                '<input type="number" class="layui-input slnumbers" id="sl'+row.hpid+'"  value="'+ value +'"  name="sl" min="1" step="1"  style="width:180px; height: 30px;border-radius: 5px;border-radius: 5px;"/>'
                /* '<input type="text" id="pdsl'+row.id+'"  name="pdsl" value="'+ value +'" style="width:80px;"/>',*/
            ].join('')
        }

        /* window.getSl=function(row,index){
         alert($("#sl2").val());
         /!*   alert($("#sl2").val());*!/
         alert(index);
         console.info("row");
         console.info(row);
         /!*row.sl=$("#sl2").val();*!/
         $tableParts.bootstrapTable('append', json);
         $table.bootstrapTable('updateRow', {index: index, row: row});
         }*/
        /*
         $("#sl2").on('change',function (row,index) {
         console.info("sfdf");
         alert("sfdf");
         alert("index:"+index);
         })*/
        // 配件保存
        $('#pjSave').click(function () {
            var reg=/^[1-9]{1,}[\d]*$/;
            if(!$("#sl").val().match(reg)){
                layer.msg("请输入正整数！");
                $("#sl").val("1");
            }else {
                if ($('#hpid').val() == null || $('#hpid').val() == "") {
                    layer.msg("货品编号不可为空");
                } else {
                    var sl = $('#sl').val();
                    var strs = $('#hpid').val().split(",");
                    var rows = $tableParts.bootstrapTable('getData');
                    console.info(rows);
                    var flag = true;
                    console.info("strs");
                    console.info(strs);
                    var hpid = strs[0];
                    var hpmc = strs[1];
                    var hzmc = strs[2];
                    var indexs;
                    for (var i = 0; i < rows.length; i++) {
                        console.info(rows[i].hpid);
                        if (rows[i].hpid == hpid) {
                            indexs = i;
                            flag = false;
                        }
                    }
                    if (flag == true) {
                        var json = {
                            "hpid": hpid,
                            "hzmc": hzmc,
                            "bh": $("#hpid").select2('data')[0].text,
                            "mc": hpmc,
                            "sl": sl
                        };
                        $('#gysid').select2('val', 'all');
                        $("#yxj").val(Number($("#yxj").val()) + Number(1));
                        $tableParts.bootstrapTable('append', json);
                    } else {
                        layer.confirm('发现货品' + hpmc + ' 已经存在,是否合并？', function (index) {
                            rows[indexs].sl = Number($("#sl" + hpid).val()) + Number(sl);
                            $tableParts.bootstrapTable('updateRow', {index: indexs, row: rows[indexs]});
                            /*var total=Number($("#sl"+hpid).val())+Number(sl);
                         $tableParts.bootstrapTable('updateCell', {
                         index : indexs,
                         field: 'sl',
                         value: total
                         });*/

                        layer.close(
                            index);
                    });
                    /* layer.msg("货品已存在");*/
                }
            }
            }
        });



        //采集序列号checkbox的选值
        $(".zhhp").click(function(){
            $(".zhhp").attr("checked","checked");
            element.init();
        })
        // 选中
        $('xxx').attr('checked', true);
        form.render();
        // 取消
        $('xxx').removeAttr('checked');
        form.render();

        // 编辑保存
        form.on("submit(addSave)",function(data){


           /* $("#qzfs option").each(index,elem){
                console.info(elem);
             /!*   if(elem.disabled== 1){
                    str .='<option value="禁用" disabled="">禁用</option>'
                }
                str .='<option value="可用" >可用</option>'*!/
            }*/


            var form=data.field;
            var gys=$table.bootstrapTable('getData');//供应商
            var pj=$tableParts.bootstrapTable('getData');//配件
            /*  for(var i=0;i<pj.length;i++){
             pj[i].sl=$("#sl"+pj[i].hpid).val()
             }*/

            if (gys.length == 0) {
                layer.msg("货品未绑定供应商，请绑定");
            } else if ($("#zhhp").val() == 1 && pj.length == 0) {
                layer.msg("请选择货品配件");
            } else  if($("#jhwzlx").val()!=0 && ($("#zkwid").val()==null||$("#zkwid").val()=="")  ){
                layer.msg("主单位库位不可为空");
            }else  if($("#jhwnlx").val()!=0 && ($("#nkwid").val()==null||$("#nkwid").val()=="")  ){
                layer.msg("内包装库位不可为空");
            }else  if($("#jhxnlx").val()!=0 && ($("#xkwid").val()==null||$("#xkwid").val()=="")  ){
                layer.msg("箱包装库位不可为空");
            }else if($("#zlid").val()==null || $("#zlid").val()==""){
                layer.msg("货品种类不可为空");
            } else {
                form.gys = gys;
                form.pj = pj;
                zzpUtils.confirm("是否确定修改", function (index) {
                    zzpUtils.action({
                        url: "/wmsgoods/edit",
                        data: JSON.stringify(form),
                        success: function (data) {
                            setTimeout(function () {
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                                top.layer.msg(data.title + '<br>' + data.message);
                            }, 500);
                        }, error: function (xhr, textStatus) {
                            console.log(textStatus);
                            console.log(xhr)
                        }
                    })
                });
            }
            return false;
        });

////                $.ajax({
////                    type: 'post',
////                    url: '/zxbzwms/wmsgoods/add',
////                    contentType:"application/json",
////                    async: true,
////                    data: JSON.stringify({
////                        ids: ids,
////                    }),
////                    success: function (res){
////                        return (res);
////                    }
////                });
////            })
    });


</script>
</html>